<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>vue导航</title>
  <style media="screen">
    * {
      margin: 0;
      padding: 0;
    }

    ul li {
      list-style: none;
    }

    .navul {
      margin: 100px auto 20px;
      overflow: hidden;
    }

    .navul li {
      background-color: #5597b4;
      padding: 18px 30px;
      float: left;
      color: #fff;
      font-size: 18px;
      cursor: pointer;
    }

    .active {
      background-color: #5597b4;
    }

    .home .home,
    .new .new,
    .contact .contact,
    .service .service {
      background-color: skyblue;
    }

    .checked {
      background: #eff4f7;
    }
  </style>
</head>

<body>
  <div id="nav">
    <ul>
      <li v-for="(relation,index) in relations" v-bind:id="relation.id" v-bind:id="relation.id"
        v-bind:class="{checked:index==nowIndex}" v-on:click="relationClick(index)">
        <i></i>
        <span class="">{{relation.text}}</span>
      </li>
    </ul>
  </div>

  <script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.min.js"></script>
  <script type="text/javascript">
    var nav = new Vue({
      el: '#nav',
      data: {
        relations: [{
            text: '项目',
            id: 'program'
          },
          {
            text: '人员',
            id: 'person'
          },
          {
            text: '机构',
            id: 'organization'
          },
          {
            text: '技术',
            id: 'tech'
          },
          {
            text: '地区',
            id: 'location'
          },
          {
            text: '国家',
            id: 'country'
          }
        ],
        nowIndex: 0
        // willShow:false
      },
      methods: {
        relationClick: function (index) {

          this.nowIndex = index;
        }
      }
    });
  </script>
</body>

</html>